<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<html>
<head>
<title>还款申请出纳审批信息</title>
<%@include file="/common/ec.jsp"%>
<%@include file="/common/meta.jsp"%>
</head>
<body>

<div class="x-panel-header">还款申请出纳审批</div>
<div style="width: 100%;">

 <table width="100%" >
  <tr>
	  <td>
		  <s:hidden name="model.id" />
		    <table width="60%" border="1" align="left" cellpadding="0" cellspacing="0" style="padding:10px 10px 10px 10px;border-collapse: collapse; border-left-width:0px; border-top-width:0px; padding: 4px 2px; margin-top: 10px;">
		    <c:set value="${rePay}" var="rePay" scope="request"/>	
		    <c:set value="${flow}" var="flow" scope="request"/>	
			<tr height="20" style="padding: 8px 2px;"> 
	           <td align="center" colspan="4"><font size="3">还款单</font></td>
	        </tr>	
			<tr height="20" style="padding: 10px 2px; padding-left: 26px;"> 
	           <td align="left" colspan="4">还款部门：
	           ${rePay.dept.name}
	           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;还款人：<stc:username></stc:username>
	           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;还款时间：${createDate}
	           </td>
	        </tr>	
	        <tr height="20" style="padding: 8px 2px;"> 
	           <td align="right" width="85">还款单号：</td>
	           <td align="left" colspan="3">${rePay.singleNo}</td>
	        </tr>   
	              
	        <tr height="20" style="padding: 8px 2px;"> 
	           <td align="right" width="85">摘&nbsp;&nbsp;&nbsp;&nbsp;要：</td>
	           <td align="left" colspan="3">${rePay.title}</td>
	        </tr>  
	
	        <tr height="20" style="padding: 8px 2px;"> 
	           <td align="right" width="85">借款单号：</td>
	           <td align="left" colspan="3">${rePay.borrow.singleNo}</td>
	        </tr>  
	 
	 		<tr height="20" style="padding: 8px 2px;"> 
	           <td align="right" width="85">借款金额：</td>
	           <td align="left" width="210">${rePay.borrow.amount}</td>
	           <td align="right">还款金额：</td>
	           <td align="left" width="128">${rePay.amount}</td>	  
	        </tr>
	
			<tr height="20" style="padding: 8px 2px;"> 
				<td align="right" width="85">备&nbsp;&nbsp;&nbsp;&nbsp;注：</td>
				<td align="left" colspan="3" style="padding-left: 0px;">${rePay.descn}</td>
			</tr>	
		    </table>
	  </td>  
   </tr>
   <tr>
     <td>
		<s:form action="save" id="save" validate="true" method="POST">
	    <s:hidden name="model.id" id="flowId"/>
	    <input type="hidden"" id="projectId" value="${borrow.project.id}">
	    <fieldset style="width: 514px; padding:10px 10px 10px 10px;">
	          <legend>【<stc:userdept></stc:userdept>】</legend>
		<table width="100%" align="center">
		  <tr height="20">
			<td align="right" width="100">&nbsp;&nbsp;&nbsp;审&nbsp;核&nbsp;人：</td>
			<td align="left" width="90">
			    <stc:username></stc:username>
			</td>
			<td align="right" width="100">审批时间：</td>
			<td align="left" width="400">
			    ${audDate}
			</td>
		  </tr>	  
		  <tr height="20">
		    <td align="right">是否通过：</td>
		    <td colspan="3">
		    	<s:radio list="isAgreeMap" id="isAgree" name="isAgree" onchange="setAgreeValue(this.value)"  cssStyle="border:0px;"/> 
	            <font color="red">*</font>
	        </td>
		  </tr>
		  <tr height="20">
		    <td align="right">具体意见：</td>
			<td align="left" colspan="3">
			  <textarea rows="4" name="descn" style="width:300px;" id="descn" ></textarea>
			  <font color="red">*</font>
		    </td>
		  </tr>
		</table>
		</fieldset>
		</s:form>   
     </td>
   </tr>
   <tr>
     <td>
		<table width="100%">
		<tr>
			<td style="text-align: center;">
                <input type="button" value="保存" class="button" onclick="return auditSave()"/>&nbsp;&nbsp;
				<s:reset value="返回" cssClass="button" onclick="javascript:history. back();" />
			</td>
		</tr>
	   </table>	    
     </td>
   </tr>
</table>
</div>


<script type="text/javascript">
var agreeVal = null;
function setAgreeValue(aValue) {
	agreeVal = aValue;
}	
function auditSave() {
	var type = "rePay";
	var projectId = document.getElementById("projectId").value;
	var fId = document.getElementById("flowId").value;
	var descn = document.getElementById("descn").value;
	if (agreeVal == null || agreeVal == "") {
		alert("请您选择审批是否通过！");
		return false;
	}
	if (descn == null || descn == "") {
		alert("请您填写具体意见！");
		return false;
	}
	if (confirm("您确认要审批此还款申请单吗？")){
  	     $.ajax({
			url: '${ctx}/flow/saveAuditResult.do',
			type: 'post',
			dataType: 'json',
			data: {type : type, flowId : fId, isAgree : agreeVal, descn: descn},
			success: function(rst, textStatus){
	  		  if(rst.result == "success"){
	  			window.location = '${ctx}/flow/rePayIndex.do';	      	  		
	  	  	  }else{
	  	  		alert("审核失败，请重试...");
	  	  	  }
			}
	  	 });		
		return true;
	}else {
		return false;
	}
}	
</script>
</body>
</html>